<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" template="../../index.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://xmlns.jcp.org/jsf/core">


    <ui:define name="content">
        <h:form id="form">
            <p:growl
                id="growl"
                showDetail="true"
                sticky="false"/>


            <div align="center">
                <p:panel header="Realizar Compra">

                    <h:inputHidden value="#{comprasBean.compra.id}"/>

                    <p:panelGrid columns="2">

                        <h:outputLabel for="mask" value="Data "/>
                        <p:calendar value="#{comprasBean.compra.data}"
                                    id="mask" pattern="dd/MM/yyyy" mask="true" showOn="button">
                        </p:calendar>

                        <h:outputText value="Quantidade"/>
                        <p:inputText value="#{comprasBean.compra.quantidade}"/>

                        <h:outputText value="Distribuidor"/>
                        <p:selectOneMenu value="#{comprasBean.compra.distribuidor}"
                                         converter="distribuidorConverter">
                            <f:selectItem itemLabel="Selecione" noSelectionOption="true"/>
                            <f:selectItems value="#{disbribuidorBean.distribuidores}"
                                           var="dist"
                                           itemLabel="#{dist.nome}"
                                           itemValue="#{dist}"/>
                        </p:selectOneMenu>

                        <h:outputText value="Batedor"/>
                        <p:selectOneMenu value="#{comprasBean.compra.batedor}"
                                         converter="batedorConverter">
                            <f:selectItem itemLabel="Selecione" noSelectionOption="true"/>
                            <f:selectItems value="#{batedorBean.batedores}"
                                           var="bate"
                                           itemLabel="#{bate.nome}"
                                           itemValue="#{bate}"/>
                        </p:selectOneMenu>

                        <h:outputText value="Cesto Venda"/>
                        <p:selectOneMenu value="#{comprasBean.compra.cestoDistribuidor}"
                                         converter="cestoDistConverter">
                            <f:selectItem itemLabel="Selecione" noSelectionOption="true"/>
                            <f:selectItems value="#{cestoDistribuidorBean.cestos}"
                                           var="cesto"
                                           itemLabel="#{cesto.capacidade}"
                                           itemValue="#{cesto}"/>
                        </p:selectOneMenu>

                    </p:panelGrid>

                    <div align="center">
                        <p:menuButton value="Opções">
                            <p:menuitem value="Salvar" action="#{comprasBean.salvar()}" update="growl" icon="ui-icon-disk"/>
                            <p:menuitem value="Cancelar" action="#{comprasBean.cancelar()}" update="growl" icon="ui-icon-arrowrefresh-1-w"/>
                            <p:separator />
                            <p:menuitem value="Voltar Página Inicial" url="../../index.xhtml" icon="ui-icon-extlink"/>
                        </p:menuButton>
                    </div>
                </p:panel>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
